package com.techysky.service;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DateUtil {
	private static Log log=LogFactory.getLog(DateUtil.class);
	public DateUtil() {
	}

	public static long fromDateStringToLong(String inVal) { // 此方法计算时间毫秒
		Date date = null; // 定义时间类型
		SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			date = inputFormat.parse(inVal); // 将字符型转换成日期型
		} catch (Exception e) {
			log.info(e);
		}
		if(null!=date)
		return date.getTime(); // 返回毫秒数
		else
			return 0;
	}

	public static String nowDate() { 
		Date date = new Date();
		SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String today =inputFormat.format(date); 
		return today; // 返回当前时间
	}
	public static long timeCalculation(long stime,long etime) { 
		long ss = (etime - stime) / (1000*60); //共计分钟数
		return ss; 
	}

}
